package org.jsbd.boss.service.impl;

import java.util.List;
import java.util.Map;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.ICommentDao;
import org.jsbd.boss.domian.Comment;
import org.jsbd.boss.service.ICommentService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("commentService")
public class CommentServiceImpl implements ICommentService {

	@Autowired
	private ICommentDao commentDao;

	@Override
	public void save(Comment comment) {
		commentDao.save(comment);
	}

	@Override
//	@Transactional("transactionManagerCrack")
	public void save(List<Comment> list) {
		commentDao.save(list);
	}

	@Override
	public void update(Comment comment) {
		commentDao.update(comment);
	}

	// @Override
	// public Comment get(Comment comment) {
	// return commentDao.get(comment);
	// }

	@Override
	public Comment getByMark(String mark) {
		Comment comment = commentDao.getByMark(mark);
		if (comment == null) {
			commentDao.updateUsedByMark(mark);
			comment = commentDao.getByMark(mark);
		}
		return comment;
	}

	@Override
	public Comment getById(Integer id) {
		return commentDao.getById(id);
	}

	@Override
	public List<Comment> getList(Comment comment) {
		return commentDao.getList(comment);
	}

	@Override
	public Map<String, Object> getListPage(DataGridModel page, Comment comment) {
		return commentDao.getListPage(page, comment);
	}

	@Override
	public void delete(List<Integer> ids) {
		commentDao.delete(ids);
	}
}
